﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.NumericalIntegration
{
    /// <summary>
    /// This class represents an abstract layer for all multivariate integrators.
    /// </summary>
    [Serializable]
    public abstract class AbstractMultivariateIntegrator
    {
        /// <summary>
        /// The needed iterations for the numerical integration.
        /// </summary>
        protected int neededIterations;

        /// <summary>
        /// Saves if the numerical integration has a precision error.
        /// </summary>
        protected bool precisionError;

        /// <summary>
        /// Saves the relative error of the numerical integration.
        /// </summary>
        protected double relativeError;

        /// <summary>
        /// Gets a value indicating whether the numerical integration has a precision error.
        /// If true the result of the numerical integration has a precision error otherwise, false.
        /// </summary>
        /// <value>True the result of the numerical integration has a precision error otherwise, false.</value>
        public bool PrecisionError
        {
            get { return precisionError; }
        }

        /// <summary>
        /// Gets the needed iterations for the numerical integration.
        /// </summary>
        /// <value>The needed iterations for the numerical integration.</value>
        public int NeededIterations
        {
            get { return neededIterations; }
        }

        /// <summary>
        /// Gets a value indicating the size of the relative error of the result. 
        /// </summary>
        /// <value>A value indicating the size of the relative error of the result.</value>
        public double RelativeError
        {
            get { return relativeError; }
        }

        /// <summary>
        /// Integrates the integral in a numerical way. After running the numerical integration
        /// it should be checked if the result has a precision error.
        /// </summary>
        /// <param name="iterations">The maximum numbers of iterations.</param>
        /// <param name="precision">The minimum precision of the numerical integration.</param>
        /// <returns>The area of the specified integral.</returns>
        public abstract double Integrate(int iterations, double precision);
    }
}